using DeathReportManagement.Data;
using DeathReportManagement.Models;

namespace DeathReportManagement.Services;

public class OperationLogService
{
    private readonly DeathReportContext _context;
    
    public OperationLogService(DeathReportContext context)
    {
        _context = context;
    }
    
    public async Task LogAsync(int? reportId, string operation, int userId, string? remark = null)
    {
        var log = new OperationLog
        {
            ReportId = reportId,
            Operation = operation,
            UserId = userId,
            OperateTime = DateTime.Now,
            Remark = remark
        };
        
        _context.OperationLogs.Add(log);
        await _context.SaveChangesAsync();
    }
}